#ifndef _MY_SCENE_OBJECT_BASE_H_
#define _MY_SCENE_OBJECT_BASE_H_

#include "cocos2d.h"
#include "myobject.h"

#include <string>
#include <list>

using namespace std;
using namespace cocos2d;

namespace fireplane
{
	class Player;

	class SceneObjectBase : public Object{
	public:
		SceneObjectBase();
		virtual ~SceneObjectBase();

		enum SceneObjectCollisionBoxType{
			SOCBT_RECT = 0,
			SOCBT_BOX,
		};

		SceneObjectCollisionBoxType getSOCBT(){
			return _collisionType;
		}

		static SceneObjectBase* create(string filename,CCPoint pos,float angle,float s_x,float s_y);
		virtual void init(string fileName,CCPoint pos,float angle,float s_x,float s_y);

		void update(float delta);
		virtual void onVisible(bool flag);
		virtual CCRect getCollisionRect();
		CCNode* getSceneObjectParent();
		virtual void onAttack(bool kill);

		void add2AcitiveList(SceneObjectBase* object);
		void removeFromActiveList(SceneObjectBase* object);
		static list<SceneObjectBase*>& getAllActiveSceneObject(); 

		virtual bool isCollision2Something(CCPoint worldPos);
		virtual bool isCollision2Player(Player* player);
		virtual void onCollision2Player();

		bool isActive(){
			return !_is_not_active && !_is_destroyed;
		}
	protected:
		CCSprite* _node;
		bool _lastVisible;
		string _debugName;
		bool _is_not_active;

		static list<SceneObjectBase*> _all_active_sceneobject;

		SceneObjectCollisionBoxType _collisionType;
		bool _is_destroyed;
	};

	class BgObject : public CCNode{
	public:
		BgObject();
		~BgObject();

		void update(float delta);

		static BgObject* create(string filename,CCPoint pos);
		virtual void init(string fileName,CCPoint pos);
		virtual const CCSize& getContentSize();
	protected:
		CCSprite* _node;
	};
}

#endif